# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gss
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
pkgver=1.0.4
pkgrel=1
pkgdesc="GNU Generic Security Service (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.gnu.org/software/gss/"
msys2_repository_url="https://git.savannah.gnu.org/cgit/gss.git"
license=("GPL")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-gtk-doc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "texinfo"
  "help2man"
)
depends=(
  "${MINGW_PACKAGE_PREFIX}-gcc-libs"
  "${MINGW_PACKAGE_PREFIX}-shishi"
)
source=(https://ftp.gnu.org/gnu/gss/${_realname}-${pkgver}.tar.gz{,.sig}
        001-autoconf.patch)
sha256sums=('ecceabdef4cae3fce7218b2ecb83eb4227dba44b53b61b8c2b2e88ae02419c73'
            'SKIP'
            'eb2bfe34d3ad1cc1292f087b527be4402e471ad881a73ea18de3579f4ce85a3c')
validpgpkeys=('B1D2BD1375BECB784CF4F8C4D73CF638C53C06BE') # Simon Josefsson <simon@josefsson.org>

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/001-autoconf.patch
  touch doc/Makefile.gdoc

  WANT_AUTOMAKE=latest autoreconf -fi

  # Fix outdated wint_t.m4
  cp lib/gl/m4/wint_t.m4 ./m4
}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make -j1
}

package() {
  cd build-${MSYSTEM}
  make DESTDIR="${pkgdir}" install
}
